package com.jinzhi.jzweb.controller.moduleConfig;


import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.pojo.moduleConfig.RecordPointsDO;
import com.jinzhi.jzweb.pojo.statistics.ModuleScoreProportionVo;
import com.jinzhi.jzweb.pojo.statistics.ScoreIntervalVo;
import com.jinzhi.jzweb.pojo.statistics.StuResultsTeamAVo;
import com.jinzhi.jzweb.pojo.statistics.StuResultsTotalVo;
import com.jinzhi.jzweb.service.ExaminationResultsComService;
import com.jinzhi.jzweb.strategy.factory.PayStrategyFactory;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 
 * <pre>
 * 考生报名   第一次加密
 * </pre>
 * <small> 2023-05-05 08:52:02 | lance</small>downloadImportStu
 */
@Controller
@RequestMapping("/recordPoints")
@Api(value = "录分管理", tags = "录分管理")
public class RecordPointsController extends BaseController {


	private final PayStrategyFactory payStrategyFactory;

	private final ExaminationResultsComService examinationResultsComService;

	public RecordPointsController(PayStrategyFactory payStrategyFactory, ExaminationResultsComService examinationResultsComService) {
		this.payStrategyFactory = payStrategyFactory;
		this.examinationResultsComService = examinationResultsComService;
	}



	@ApiOperation(value = "录分导出", notes = "录分导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/downloadMark")
	@ResponseBody
	public void downloadMark(HttpServletResponse response,String field)  throws Exception {
		payStrategyFactory.get(field).downloadImportTemplate(response,field);
	}

	@ApiOperation(value = "机考分数导出", notes = "机考分数导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场A", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/downloadImportBased")
	@ResponseBody
	public void downloadImportBased(HttpServletResponse response,String field)  throws Exception {
		payStrategyFactory.get(field).downloadImportBased(response,field);
	}


	@ApiOperation(value = "录分", notes = "录分")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "resultsComDO", value = "录分信息", required = true, dataType = "RecordPointsDO")
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/recordPoints")
	@ResponseBody
	public Result recordPoints(@RequestBody RecordPointsDO resultsComDO) throws Exception {
		return payStrategyFactory.get(resultsComDO.getField()).recordPoints(resultsComDO);
	}


	@ApiOperation(value = "根据赛场分页查询录分信息", notes = "根据赛场分页查询录分信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
			@ApiImplicitParam(name = "current", value = "当前页", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "status", value = "0 = 查机考，1 = 查婴幼儿早期教育发展分析", required = true, dataType = "Integer"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getScoreInfoPage")
//	@RequiresPermissions("jzweb:getScoreInfoPage:getScoreInfoPage")
	@ResponseBody
	public Result getScoreInfoPage(String field,Integer current,Integer size,Integer status) throws Exception {
		return payStrategyFactory.get(field).getScoreInfoPage(field,current,size,status);
	}



	@ApiOperation(value = "根据赛场分页查询统计信息", notes = "根据赛场分页查询统计信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
			@ApiImplicitParam(name = "current", value = "当前页", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "Integer"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = StuResultsTeamAVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getStatisticsByfield")
	@ResponseBody
	public Result getStatisticsByfield(String field,Integer current,Integer size) throws Exception {
		return Result.ok(payStrategyFactory.get(field).getStatisticsByfield(field,current,size,null));
	}


	@ApiOperation(value = "根据赛场导出成绩信息", notes = "根据赛场导出成绩信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getStatisticsDownload")
	@ResponseBody
	public void getStatisticsDownload(HttpServletResponse response,String field)  throws Exception {
		payStrategyFactory.get(field).getStatisticsDownload(response,field);
	}


	@ApiOperation(value = "根据赛场查询参数人数、最高分、最低分", notes = "根据赛场查询参数人数、最高分、最低分")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getStuResulteHeader")
	@ResponseBody
	public Result getStuResulteHeader(String field)  throws Exception {
		return payStrategyFactory.get(field).getStuResulteHeader(field);
	}


	@ApiOperation(value = "分页查询成绩总统计信息", notes = "分页查询成绩总统计信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "current", value = "当前页", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "Integer"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = StuResultsTotalVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getStuResulteTotal")
	@ResponseBody
	public Result getStuResulteTotal(Integer current,Integer size){
		return Result.ok(examinationResultsComService.getStuResulteTotal(current,size));
	}


	@ApiOperation(value = "成绩总统计导出", notes = "成绩总统计导出")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = StuResultsTotalVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/documenResulte")
	@ResponseBody
	public void documenResulte(HttpServletResponse response){
		examinationResultsComService.documenResulte(response);
	}


	@ApiOperation(value = "成绩公示表导出", notes = "成绩公示表导出")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = StuResultsTotalVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/documentResulteWord")
	@ResponseBody
	public void documentResulteWord(HttpServletResponse response) throws Exception{
		examinationResultsComService.documentResulteWord(response);
	}



	@ApiOperation(value = "得分区间统计", notes = "得分区间统计")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = ModuleScoreProportionVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/proportionOfTotalScore")
	@ResponseBody
	public Result proportionOfTotalScore(){
		return Result.ok(examinationResultsComService.proportionOfTotalScore());
	}


	@ApiOperation(value = "总得分占比情况统计", notes = "总得分占比情况统计")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = ModuleScoreProportionVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/moduleScoreProportion")
	@ResponseBody
	public Result moduleScoreProportion(){
		return Result.ok(examinationResultsComService.moduleScoreProportion());
	}



	@ApiOperation(value = "各模块得分情况统计", notes = "各模块得分情况统计")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功",response = ScoreIntervalVo.class),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/scoreInterval")
	@ResponseBody
	public Result scoreInterval(){
		return Result.ok(examinationResultsComService.scoreInterval());
	}




	/** 考生文件导出 */
	@ApiOperation(value = "压缩包下载", notes = "压缩包下载")
	@ApiImplicitParams({
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@ResponseBody
	@GetMapping(value = "/stuFileDownload")
	public  Result  stuFileDownload(HttpServletResponse response){
		return examinationResultsComService.stuFileDownload(response);
	}
}
